<!DOCTYPE html>
<html lang="ch">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Needingcen's Private TV Show</title>
    <link rel="stylesheet" href="/static/css/main.css">
    <style>
        :root {
            --bg-primary: #f9f9f9;
            --bg-secondary: #e9ecef;
            --text-primary: #333;
            --text-secondary: #6c757d;
            --card-bg: #fff;
            --card-shadow: rgba(0, 0, 0, 0.1);
            --link-color: #EC6F2F;
            --link-hover: #a1591a;
            --video-bg: #fff;
            --video-title: #343a40;
            --nav-bg: #d6d6d6;
            --list-bg: #f1f1f1;
            --list-hover: #f8f9fa;
            --container-bg: #f8f9fa;
            --folder-name-color: #18191c;
        }

        :root[data-theme="dark"] {
            --bg-primary: #1a1a1a;
            --bg-secondary: #2d2d2d;
            --text-primary: #ffffff;
            --text-secondary: #cccccc;
            --card-bg: #333333;
            --card-shadow: rgba(255, 255, 255, 0.1);
            --link-color: #ff8f4c;
            --link-hover: #ff6b1a;
            --video-bg: #2d2d2d;
            --video-title: #ffffff;
            --nav-bg: #2d2d2d;
            --list-bg: #333333;
            --list-hover: #404040;
            --container-bg: #2d2d2d;
            --folder-name-color: #ffffff;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
            min-height: calc(100vh - 0px); /* 动态高度计算 */
            background: var(--container-bg);
            border-radius: 16px;
            box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
            overflow-y: auto;
            display: flex;          /* 新增 */
            flex-direction: column;/* 新增 */
            justify-content: space-between; /* 新增 */
        }

        @media (max-width: 768px) {
            .container {
                min-height: calc(100vh - 150px);
                padding: 15px;
            }
        }
        .header {
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 20px 40px;
            background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
            border-radius: 0 0 16px 16px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            gap: 20px;
            min-height: 100px;
        }
        p {
            font-size: 2.5rem;
            color: var(--text-primary);
            font-weight: 600;
            text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.5);
            margin: 0;
        }
        .folder-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
            gap: 20px;
            padding: 20px 0;
        }

        .folder-card {
            background: var(--card-bg);
            border-radius: 8px;
            overflow: hidden;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
            transition: transform 0.2s ease;
            cursor: pointer;
            padding: 20px;
            text-align: center;
        }

        .folder-card:hover {
            transform: translateY(-4px);
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
        }

        .folder-icon {
            font-size: 48px;
            color: var(--link-color);
            margin-bottom: 10px;
        }

        .folder-name {
            font-size: 18px;
            color: var(--folder-name-color);
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .footer {
            text-align: center;
            padding: 30px 20px;
            padding-bottom: 0px;
            margin-top: 40px;
            background: linear-gradient(145deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
            border-radius: 16px 16px 0 0;
            box-shadow: 0 -4px 6px rgba(0, 0, 0, 0.05);
            color: #6c757d;
            font-size: 0.9rem;
        }

        .footer a {
            color: var(--link-color);
            text-decoration: none;
            font-weight: 500;
            transition: color 0.3s ease;
            margin: 0 8px;
        }

        .footer a:hover {
            color: #138496;
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <img src="../static/logo.png" alt="logo" style="height: 60px; filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.1))">
            <p>
                Hacktb Media
            </p>
            <button class="theme-toggle" id="theme-toggle" aria-label="Toggle theme">
                <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
                    <path class="sun" d="M12 2.25a.75.75 0 01.75.75v2.25a.75.75 0 01-1.5 0V3a.75.75 0 01.75-.75zM7.5 12a4.5 4.5 0 119 0 4.5 4.5 0 01-9 0zM18.894 6.166a.75.75 0 00-1.06-1.06l-1.591 1.59a.75.75 0 101.06 1.061l1.591-1.59zM21.75 12a.75.75 0 01-.75.75h-2.25a.75.75 0 010-1.5H21a.75.75 0 01.75.75zM17.834 18.894a.75.75 0 001.06-1.06l-1.59-1.591a.75.75 0 10-1.061 1.06l1.59 1.591zM12 18a.75.75 0 01.75.75V21a.75.75 0 01-1.5 0v-2.25A.75.75 0 0112 18zM7.758 17.303a.75.75 0 00-1.061-1.06l-1.591 1.59a.75.75 0 001.06 1.061l1.591-1.59zM6 12a.75.75 0 01-.75.75H3a.75.75 0 010-1.5h2.25A.75.75 0 016 12zM6.697 7.757a.75.75 0 001.06-1.06l-1.59-1.591a.75.75 0 00-1.061 1.06l1.59 1.591z"/>
                </svg>
            </button>
        </div>
        <div class="folder-grid" id="folder-grid">
            <!-- Folders will be populated here -->
        </div>
        <div class="footer">
            <div class="footer-content">
                Technical support: 
                <a href="https://gitee.com/a19983" target="_blank" rel="noopener">@needingcen</a>
                <a href="https://github.com/aaaaaaamua/" target="_blank" rel="noopener">@zhao55p</a>
                <a href="https://github.com/shelbyy54" target="_blank" rel="noopener">@Cyber_Kaiyo</a>
                <div class="copyright">
                    © 2025 Hacktb Media. All rights reserved.
                </div>
            </div>
        </div>
    </div>
    <script>
        // 主题切换功能
        function toggleTheme() {
            const root = document.documentElement;
            const currentTheme = localStorage.getItem('theme') || 'light';
            const newTheme = currentTheme === 'light' ? 'dark' : 'light';
            root.setAttribute('data-theme', newTheme);
            localStorage.setItem('theme', newTheme);
        }

        // 初始化主题
        document.addEventListener('DOMContentLoaded', () => {
            const root = document.documentElement;
            const savedTheme = localStorage.getItem('theme') || 'light';
            root.setAttribute('data-theme', savedTheme);

            // 绑定主题切换按钮
            document.getElementById('theme-toggle').addEventListener('click', toggleTheme);

            fetch('/videos/')
                .then(response => response.json())
                .then(videos => {
                    const folderGrid = document.getElementById('folder-grid');
                    const folders = new Set();

                    // 收集所有文件夹
                    videos.forEach(video => {
                        folders.add(video.folder);
                    });

                    // 渲染文件夹
                    folders.forEach(folder => {
                        const folderCard = document.createElement('div');
                        folderCard.className = 'folder-card';
                        folderCard.innerHTML = `
                            <div class="folder-icon">📁</div>
                            <div class="folder-name">${folder === '' ? '未分类' : folder}</div>
                        `;

                        folderCard.addEventListener('click', () => {
                            window.location.href = `/play?folder=${encodeURIComponent(folder)}`;
                        });

                        folderGrid.appendChild(folderCard);
                    });
                });
        });
    </script>
</body>
</html>